<template>
	<view>
		<u-popup :show="value" mode="center" :round="10" @close="close" :safeAreaInsetBottom="false">
			<view class="popup-bg flex flex-direction align-center justify-center">
				<text class="cr-333 font_s28">每日签到</text>
				<image src="/static/img/sign.png" class="sign-img mar-top33 mar-bottom36"></image>
				<view v-if="userInfo.checkInFlag == 0" @click="clickSign" class="sign-btn">签到</view>
				<view v-else class="signsuccess">签到成功</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	const app = getApp().globalData
	export default {
		name:"t-sign",
		props:{
			value:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				userInfo:app.userInfo,
				signShow:false
			};
		},
		methods:{
			clickSign(){
				this.$http.post('/yaolexue-service-portal/sysPortalUser/checkIn',{
					
				}).then(res => {
					if(res.code == 200){
						uni.showToast({
							title:'签到成功',
							icon:'none'
						})
						this.userInfo.checkInFlag = 0
					}else{
						uni.showToast({
							title:res.message,
							icon:'none'
						})
					}
				})
			},
			close(){
				this.signShow = false
				this.$emit('input',false)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.popup-bg{
		width: 650rpx;
		height: 376rpx;
		background: #FFFFFF;
		border-radius: 25rpx;
	}
	.sign-img{
		width: 146rpx;
		height: 159rpx;
	}
	.sign-btn{
		width: 248rpx;
		height: 63rpx;
		background: #FA312A;
		border-radius: 32rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.signsuccess{
		width: 248rpx;
		height: 63rpx;
		background: #C5C5C5;
		border-radius: 32rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center; 
	}
</style>